<?php
if (!(defined('IN_IA')))
{
    exit('Access Denied');
}
/**
 * User: 邓志锋 <280160522@qq.com> <http://www.diygw.com>
 * Date: 2018-07-28
 * Time: 下午 6:06
 */
class Page_Diygwcom extends DiygwcomAction
{
    public function index()
    {
        // 获取用户信息
        if (empty($_W['fans']['nickname'])) {
            load()->model('mc');
            mc_oauth_userinfo();
        }
        
        global $_GPC, $_W;
        $page= pdo_get(getTableName('PAGE'), array('id'=>safe_gpc_string($_GPC['pid'])), array('content','title','id','name','dashboard_id','attributes'));
        if(!$page){
            message('页面不存在', 'error');
        }
        $_SESSION['dashboardid']=$page['dashboard_id'];

        $homepageid= pdo_get(getTableName('PAGE'), array('dashboard_id'=>$page['dashboard_id'],'is_home'=>'1'), array('id'));
        if($homepageid){
            $homePage=DiygwcomUtil::to_mobile_url($this->createMobileUrl('page_index', array('m'=>'diygwcom_app','pid'=>$homepageid['id'])));
        }
        $uniacid=$_W['uniacid'];
        $attributes = json_decode($page['attributes'],true);
        $fields=$attributes['design']['fields'];
        if($fields['istitle']){
            $istitle= $fields['istitle']['value'];//是否显示标题
        }
        if($fields['backgroundColor']){
            $backgroundColor= $fields['backgroundColor']['value'];//是否显示标题
        }
        if($fields['styles']){
            $backgroundColor= $fields['styles']['value'];//是否显示标题
        }
        include $this->template();
    }

    public function emptypage(){
        global $_GPC, $_W;
        $message="你还没有定义跳转页面哟，可根据实际需要安排";
        $dashboardid = $_GPC["dashboardid"];
        $homepageid= pdo_get(getTableName('PAGE'), array('dashboard_id'=>$dashboardid,'is_home'=>'1'), array('id'));
        if($homepageid){
            $homePage=DiygwcomUtil::to_mobile_url($this->createMobileUrl('page_index', array('m'=>'diygwcom_app','pid'=>$homepageid['id'])));
        }
        include $this->template("login/perror");
    }

}